package com.project.quiktask;

import java.sql.Date;
import java.sql.Time; // perhaps we can use the java Calendar class for this?
import java.util.Vector;

import com.project.quiktask.datastore.FileConverter;

public class Task {	
	private String taskDescription;
	private Date startDate;
	private Date endDate;
	private Date deadlineDate;
	private Time startTime;
	private Time endTime;
	private Time deadlineTime;
	private boolean importance;
	
	public Task(String taskDescription, Date startDate, Date endDate,
			Date deadlineDate, Time startTime, Time endTime, Time deadlineTime, boolean importance) {
		this.taskDescription = taskDescription;
		this.startDate = startDate;
		this.endDate = endDate;
		this.deadlineDate = deadlineDate;
		this.startTime = startTime;
		this.endTime = endTime;
		this.deadlineTime = deadlineTime;
		this.importance = importance;
	}

	public Task() {
		this.setTaskDescription(null);
		this.setStartDate(null);
		this.setEndDate(null);
		this.setStartTime(null);
		this.setEndTime(null);
		this.setDeadlineDate(null);
		this.setDeadlineTime(null);
		this.setImportance(false);
	}
	
	public Task(Task newTask) {
		this.taskDescription = newTask.getTaskDescription();
		this.startDate = newTask.getStartDate();
		this.endDate = newTask.getEndDate();
		this.startTime = newTask.getStartTime();
		this.endTime = newTask.getEndTime();
		this.deadlineDate = newTask.getDeadlineDate();
		this.deadlineTime = newTask.getDeadlineTime();
		this.importance = newTask.getImportance();
	}
	
	
	public String getTaskDescription() {
		return taskDescription;
	}

	public void setTaskDescription(String taskDescription) {
		this.taskDescription = taskDescription;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Date getDeadlineDate() {
		return deadlineDate;
	}

	public void setDeadlineDate(Date deadlineDate) {
		this.deadlineDate = deadlineDate;
	}

	public Time getStartTime() {
		return startTime;
	}

	public void setStartTime(Time startTime) {
		this.startTime = startTime;
	}

	public Time getEndTime() {
		return endTime;
	}

	public void setEndTime(Time endTime) {
		this.endTime = endTime;
	}

	public Time getDeadlineTime() {
		return deadlineTime;
	}
	
	public void setDeadlineTime(Time deadlineTime) {
		this.deadlineTime = deadlineTime;
	}

	public void setImportance(boolean importance) {
		this.importance = importance;
	}
	
	public String toStartString(){
		String timeStartString=(startTime==null? "":startTime.toString());
		String dateStartString=(startDate==null? "":startDate.toString());
		return timeStartString+ " " + dateStartString;
	}
	 
	public String toEndString(){
		String timeEndString=(endTime==null? "":endTime.toString());
		String dateEndString=(endDate==null? "":endDate.toString());
		return timeEndString+ " " + dateEndString;
	}
	
	public String toDeadlineString() {
		String deadlineTimeString=((deadlineTime==null)? "":deadlineTime.toString());
		String deadlineDateString=((deadlineDate==null)? "":deadlineDate.toString());
		return deadlineTimeString + " " + deadlineDateString;
	}
	
	public String toString() { 
		return taskDescription + ", " + toStartString() + ", " + toEndString() + ", " + toDeadlineString(); }
	
	public Vector<Object> convertTaskData(int order){
		Vector<Object> taskVector=new Vector<Object>();
		if (getImportance())
			taskVector.add("*");
		else{ 
			taskVector.add(null);
		}
		taskVector.add(order);
		taskVector.add(taskDescription);
		taskVector.add(toStartString());
		taskVector.add(toEndString());
		taskVector.add(toDeadlineString());
		
		return taskVector;
	}
	
	public boolean getImportance() {
		return importance;
	}
	
	public boolean equalTo(Task task){
		return FileConverter.taskObjectToString(task).equals(FileConverter.taskObjectToString(this));
	}
	
}